#include("/front/teacher/_layout.html")
#@layout()
#define layoutImportcss()
#end
#define layoutHead()
	<title>设置</title>
#end
#define layoutHome()

<div class="page-content patriarch-page-content">
<div class="navbar">
	<div class="navbar-inner toolbstyle">
		<div class="left">
			<a class="link external back" href="javascript:history.back()">
				<i class="icon icon-back"></i>
			</a>
		</div>
		<div class="title">设置</div>
		<div class="right"></div>
	</div>
</div>

	<div class="list">
		<ul>
			<a class="item-link popup-open" data-popup=".popup-update-password">
			<li>
				<div class="item-content">
					<div class="item-inner">
						<div class="item-title">修改密码</div>
						<div class="item-value"></div>
					</div>
				</div>
			</li>
			</a>
		</ul>
	</div>
	<div><button id="a_logout" class="button button-fill botton-width" style="margin-top: 10px;">退出登录</button></div>
	
	<div class="popup popup-update-password">
		<div class="block">
			<p class="popup-input"><input type="password" name="old_password" id="old_password" placeholder="输入原始密码"></p>
			<p class="popup-input"><input type="password" name="new_password" id="new_password" placeholder="输入新密码"></p>
			<p class="popup-input"><input type="password" name="re_password" id="re_password" placeholder="输入新密码确认"></p>
			  <!-- Close Popup -->
			<p><a class="link col button button-fill" id="update-password-submit" href="#">提交</a></p>
			<p><a class="link col button button-fill popup-close"  href="#">取消</a></p>
		</div>
	</div>
</div>

#end
#define layoutImportjs()
#end
#define layoutScript()
<script type="text/javascript">
	
	$$("#update-password-submit").on("click", function(){
		var surl = '/front/teacher/auth/updatePwd';
		sendPost(surl, { oldpwd: $$("#old_password").val(), 
						 newpwd: $$("#new_password").val(), 
						 newpwd2: $$("#re_password").val() 
			}, function(res){
				console.log(res);
				alert(res.msg);
				if (res.code == 200){
					app.popup.close($$('.popup-update-password'));
				}
		});
		return false;
	});
	$$("#a_logout").on("click", function(){
		var surl = '/front/teacher/auth/logout';
		sendPost(surl, null, function(res){
				//console.log(res);
				
				if (res.code == 202){
					myStorage.clear();
					window.location.href = '/front/teacher/html/login';
				}else{
					alert(res.msg);
				}
		});
		return false;
	});
</script>
#end